package com.neuedu.boot.controller;

import com.neuedu.boot.entity.Department;
import com.neuedu.boot.service.IDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 项目：      springboot
 * 类名:       DeptController
 * 创建时间：  2024/3/29 14：46
 * 描述 :
 * 作者 :     张金山
 * QQ :     314649444
 * Site:      https://jshand.gitee.io
 */

@CrossOrigin
@RestController
@RequestMapping("/dept")
public class DeptController {

    @Autowired
    IDeptService deptService;


    /**
     * http://localhost:8080/dept/list
     * @param dept
     * @return
     */
    @RequestMapping("/list")
    public List<Department> list(Department dept){
        return  deptService.list(dept);
    }

    @RequestMapping("/saveOrUpdate")
    public boolean  saveOrUpdate( @RequestBody Department dept){
        return  deptService.saveOrupdate(dept);
    }

    // @RequestMapping("/updateByPk")
    // public boolean  updateByPk(@RequestBody  Department dept){
    //     return  deptService.updateByPk(dept);
    // }

    @RequestMapping("/removeById/{id}")
    public boolean  removeById(@PathVariable  int id){
        return  deptService.removeById(id);
    }


    @RequestMapping("/getById/{id}")
    public Department getById(@PathVariable  int id){
        return  deptService.getById(id);
    }
}
